-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][DebugInfo] Remove unnessesary call to SM.getFileLoc when calling SM.getPresumedLoc
#166544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
af81e65 to
2197959
Compare
getFileLoc when calling getPresumedLoc
getFileLoc when calling getPresumedLocSM.getFileLoc when calling SM.getPresumedLoc
|
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Sergej Salnikov (SergejSalnikov) ChangesThis is no longer required after #166255 Full diff: https://github.com/llvm/llvm-project/pull/166544.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ca579c915f49d..6c1e0038a4316 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -345,7 +345,7 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
if (Loc.isInvalid())
return;
- CurLoc = CGM.getContext().getSourceManager().getFileLoc(Loc);
+ CurLoc = Loc;
// If we've changed files in the middle of a lexical scope go ahead
// and create a new lexical scope with file node if it's different
@@ -571,8 +571,9 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
// with an absolute path.
FileName = TheCU->getFile()->getFilename();
CSInfo = TheCU->getFile()->getChecksum();
+ FID = SM.getFileID(Loc);
} else {
- PresumedLoc PLoc = SM.getPresumedLoc(SM.getFileLoc(Loc));
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc);
FileName = PLoc.getFilename();
if (FileName.empty()) {
@@ -599,8 +600,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
}
- return createFile(FileName, CSInfo,
- getSource(SM, SM.getFileID(SM.getFileLoc(Loc))));
+ return createFile(FileName, CSInfo, getSource(SM, FID));
}
llvm::DIFile *CGDebugInfo::createFile(
@@ -655,7 +655,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
if (Loc.isInvalid())
return 0;
SourceManager &SM = CGM.getContext().getSourceManager();
- return SM.getPresumedLoc(SM.getFileLoc(Loc)).getLine();
+ return SM.getPresumedLoc(Loc).getLine();
}
unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -667,8 +667,7 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
if (Loc.isInvalid() && CurLoc.isInvalid())
return 0;
SourceManager &SM = CGM.getContext().getSourceManager();
- PresumedLoc PLoc =
- SM.getPresumedLoc(Loc.isValid() ? SM.getFileLoc(Loc) : CurLoc);
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
return PLoc.isValid() ? PLoc.getColumn() : 0;
}
@@ -6281,7 +6280,7 @@ void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
const StringLiteral *S) {
SourceLocation Loc = S->getStrTokenLoc(0);
SourceManager &SM = CGM.getContext().getSourceManager();
- PresumedLoc PLoc = SM.getPresumedLoc(SM.getFileLoc(Loc));
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc);
if (!PLoc.isValid())
return;
|
|
@AaronBallman, this is a follow up change for #166255 |
AaronBallman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM presuming precommit CI doesn't find any surprises
This is no longer required after #166255